home *** CD-ROM | disk | FTP | other *** search
- Path: ausnews.austin.ibm.com!hook
- From: hook@austin.ibm.com (Gary R. Hook)
- Newsgroups: comp.lang.c,comp.os.ms-windows.nt.misc,comp.programming,comp.std.c,comp.unix.aix
- Subject: Re: function pointers
- Date: 3 Feb 1996 18:20:08 GMT
- Organization: AIX Development, IBM Austin
- Sender: hook@shocker.austin.ibm.com (Gary R. Hook)
- Message-ID: <4f090o$2hn4@ausnews.austin.ibm.com>
- References: <4eogio$gt0@giga.bga.com> <4eohgr$gt0@giga.bga.com> <sXEExQ9ytBGL084yn@csn.net> <4es7vo$bih@usenet.pa.dec.com>
- NNTP-Posting-Host: shocker.austin.ibm.com
- X-newsreader: xrn 8.01
-
- In article <4es7vo$bih@usenet.pa.dec.com>, diamond@tko.dec.com (Norman Diamond) writes:
- > After seeing several followups which were either wrong or else technically
- > correct but non-responsive to the original poster's problem, and seeing
- > which newsgroups they were posted to, I wish to point out that only one
- > followup correctly answered the original poster's problem.
- >
- > Thad Smith's posting with message-id <sXEExQ9ytBGL084yn@csn.net>
- > had the correct answer (and another partial answer with correct warning).
- >
- > If you try relying on any of the others, you will get bitten someday, or
- > if not you then innocent bystanders will get bitten by your work.
-
- Begging your pardon, but pretty much every one who responded to the post
- had a "correct" answer; the original question was how to get the code
- to compile on AIX. The original code was incorrect, in that the casting
- that was being done did not really address the complaint from the
- compiler. The "solution" is to properly perform the casts to the
- associated types, i.e. function pointers taking and returning the
- required data types, as opposed to casting to struct pointers, which
- doesn't affect the function pointer in the least.
-
- The fact that what the original coder was trying to accomplish is
- quite non-portable, and can wreak havoc for others, was an appropriate
- comment by Thad, but the addition of his warning didn't make his
- answer any more correct than any of the others, did it? Or perhaps
- we saw different responses to the posed question...
-
- Finally, it may be worth pointing out that the NT MSVC++ and SVR4 C
- compiler are incorrect with respect to the ANSI standard (if that's
- what you're trying to write to) in that it is illegal to allow
- a cast _from_ an arbitrary pointer type _to_ a void pointer without
- a cast. It is perfectly permissible to allow the compiler to
- convert from void pointers to other pointer types on the fly. In
- _any_ case, it's flat-out dangerous and non-portable.
-
- Good for XL C for refusing to compile this sort of code without
- complaint.
-
- --
- ________________________________________________________________________
- Gary R. Hook | If you have any trouble sounding
- AIX Development, RS6000 Division | condescending, find a Unix user
- IBM Corporation, Austin, Texas | to show you how it's done.
- The above opinions are all mine. | -Scott Adams, author of "Dilbert"
-